package com.example.javaee.Util.sensitiveWordFilter;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

//定义前缀树
@Component
class TrieNode{
    //关键词结束标识
    private boolean isKeywordEnd = false;

    //字节点(key是下级字符，value是下级节点)
    private Map<Character,TrieNode> subNodes = new HashMap<>();

    public boolean isKeywordEnd() {
        return isKeywordEnd;
    }

    public void setKeywordEnd(boolean keywordEnd) {
        isKeywordEnd = keywordEnd;
    }

    public void addSubNode(Character c,TrieNode node){
        subNodes.put(c,node);
    }

    public TrieNode getSubNode(Character c){
        return subNodes.get(c);
    }
}